package com.xxh.springclouddemo.consumer.service;

import com.xxh.springclouddemo.common.pojo.Student;
import com.xxh.springclouddemo.consumer.interfaceApi.OpenfeignApi;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * openfeign 容错方式二
 * @Author xxh
 * @Date 2024/4/15 21:36
 */
@Component
public class OpenfeignApiFallback implements FallbackFactory<OpenfeignApi> {


    @Override
    public OpenfeignApi create(Throwable cause) {
      return new OpenfeignApi(){
          @Override
          public List<Student> getStudent() {
              Student student = new Student();
        student.setName("异常啦！！！！！");

        List<Student> studentList = new ArrayList<>();
        studentList.add(student);

        return studentList;
          }
      };

    }
}
